﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="format-detection" content="telephone=no">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
    <link href="~/Content/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="~/Content/bootstrap/css/base.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-2.1.1.min.js"></script>
    <script src="~/Content/bootstrap/js/bootstrap.js"></script>
    <script src="~/Scripts/layer/layer.js"></script>
    <script src="~/Scripts/qrcode.js"></script>
    <title>申请管理</title>
    <style type="text/css">
        body {
            font-family: arial, '宋体';
            background: white;
        }

        .container-fluid {
            margin: 0;
            padding: 0;
            text-align: center;
        }

        .btn_ok {
            background-color: #F3A433;
            border: none;
            color: white;
        }

        #update_pass {
            background-color: #F3A433;
            text-align: center;
            font-weight: bold;
            font-size: 20px;
            width: 100%;
            height: 60px;
            line-height: 60px;
        }

        #txt_password {
            margin-top: 15%;
        }

        .container-fluid {
            margin: 0;
            padding: 0;
        }

        #content_sel {
            text-align: left;
        }

        #div_mobile input {
            width: 70%;
        }
    </style>
    <script>
        $(function () {
            GetCateAndLev();

        });

        //下拉框信息
        function GetCateAndLev() {
            $("#sel_Category").html("<option value=\"-1\" code=\"0\">请选择</option>"); 
            $("#sel_Level").html("<option value=\"-1\" code=\"0\">请选择</option>");
            $.ajax({
                type: "GET",
                url: "/ShenQing/GetCateAndLev",
                dataType: "json",
                data: {},
                success: function (data) {
                    if (data.list != "") {
                        $.each(data.Catelist, function (i, n) {
                            $("#sel_Category").append("<option value='" + n.id + "'>" + n.name + "</option>");
                        });
                        $.each(data.Levlist, function (i, n) {
                            $("#sel_Level").append("<option value='" + n.id + "'>" + n.name + "</option>");
                        });
                    }
                }
            });
        }
        function CheckInputNullAll(demo) {
            var pattern = /(13\d|14[57]|15[^4,\D]|17[678]|18\d)\d{8}|170[059]\d{7}/;
            var card = /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[12])(0[1-9]|[12]\d|3[01])\d{3}(\d|X)$/i;
            var flag = true;
            var inp = $("#" + demo + "").find("input[type='text'],input[type='number']");
            $(inp).each(function (m, n) {
                if ($(n).hasClass("required") == true && $(n).val() != "") {
                    if ($(n).hasClass("tel")) {
                        if (!pattern.test($(n).val())) {
                            layer.msg($(n).attr("placeholder"), { icon: 5 });
                            flag = false;
                            return flag;
                        }
                    }
                    if ($(n).hasClass("sfz")) {
                        if (!card.test($(n).val())) {
                            layer.msg($(n).attr("placeholder"), { icon: 5 });
                            flag = false;
                            return flag;
                        }
                    }
                } else if ($(n).hasClass("required") == true && $(n).val() == "") {
                    layer.msg($(n).attr("placeholder"), { icon: 5 });
                    flag = false;
                    return flag;

                } else {
                    return flag;
                }


            })
            return flag;

        }
        function sq_click() {

            if (CheckInputNullAll("div_mobile")) {
                var txt_name = $("#txt_userName").val();
                var txt_companyName = $("#txt_companyName").val();
                var txt_contract_name = $("#txt_contartName").val();
                var txt_mobile = $("#txt_mobile").val();
                var txt_qqCode = $("#txt_qq").val();
                var txt_wxopen = $("#txt_wxCode").val();
                var txt_wwCode = $("#txt_wxCode").val();
                var txt_idcard = $("#txt_idcard").val();
                var txt_shopurl = $("#txt_shopurl").val();
                var sel_Category = $("#sel_Category").val();
                var sel_Level = $("#sel_Level").val();
                if (sel_Level == -1 || sel_Level == "") {
                    layer.msg("请选择客户级别！");
                    return false;
                }
                if (sel_Category == -1 || sel_Category == "") {
                    layer.msg("请选择客户类别！");
                    return false;
                }
                var level_name = $('#sel_Level').find("option:selected").text();

                $.ajax({
                    type: "POST",
                    url: "/ShenQing/OpeaShenQing",
                    dataType: "json",
                    data: { "id": 0, "Name": txt_name, "companyName": txt_companyName, "contract_name": txt_contract_name, "mobile": txt_mobile, "qq_code": txt_qqCode, "wxOpenid": txt_wxopen, "wwCode": txt_wwCode, "idCard": txt_idcard, "shopUrl": txt_shopurl, "category_id": sel_Category, "level_id": sel_Level, "level_name": level_name,},
                    success: function (data) {
                        if (data.MessageCode == "0") {
                            layer.msg("申请成功,请等待审核！");
                            setTimeout(function () {
                                window.location.href = "/Login/Login";
                            }, 2000)
                        } else if (data.MessageCode == "50") {
                            layer.msg("信息存在重复!");
                        } else {
                            layer.msg("申请失败！");
                        }
                    }
                });
            }


        }
    </script>
</head>
<body>
    <div class="div_mobile" id="div_mobile" >
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12" id="update_pass">
                    <span style="text-align:center;color:white;">新用户申请</span>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12" style="margin-top:10px;">
                    <h3>@ViewData["level_name"] </h3>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12" style="margin-top:10px;">
                    商家名称：<input type="text" id="txt_userName" placeholder="请输入商家名称" class="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    公司名称：<input type="text" id="txt_companyName" placeholder="请输入公司名称" class="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    联&nbsp;&nbsp;系&nbsp;&nbsp;人：<input type="text" id="txt_contartName" placeholder="请输入联系人" class="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    手&nbsp;&nbsp;机&nbsp;&nbsp;号：<input type="text" id="txt_mobile" placeholder="请输入正确的手机号码" class="tel required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    &nbsp;&nbsp; QQ&nbsp;&nbsp;号：<input type="text" id="txt_qq" placeholder="请输入QQ号" class="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    微&nbsp;&nbsp;信&nbsp;&nbsp;号：<input type="text" id="txt_wxCode" placeholder="请输入微信号" class="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    旺&nbsp;&nbsp;旺&nbsp;&nbsp;号：<input type="text" id="txt_wwcode" placeholder="请输入旺旺号" class="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    身份证号：<input type="text" id="txt_idcard" placeholder="请输入正确的身份证号" class="sfz" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    店铺网址：<input type="text" id="txt_shopurl" placeholder="请输入店铺网址" class="required" />
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    客户级别：<select style="width:75%;height:30px;" id="sel_Level">
    <option value="-1">请选择</option>
</select>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    客户类别：<select style="width:75%;height:30px;" id="sel_Category">
                        <option value="-1">请选择</option>
                    </select>
                </div>
            </div>
            <div class="row-fluid">
                <div class="span12">
                    <input type="button" id="btn_sq" onclick="sq_click();" value="提交申请" style="width: 30%; height: 30px; border: 0px; text-align: center; background-color: #F3A433; color:white; border-radius: 4px; " />
                </div>
            </div>
        </div>

    </div>
</body>
</html>
